#include<windows.h>

#define IDC_MAIN_SELECT 				10001
#define IDC_MAIN_TOOL					10002
#define IDC_MAIN_STATUS					10003

#define IDC_BLACK                       20001
#define IDC_BLUE                        20002
#define IDC_GREEN                       20003
#define IDC_CYAN                        20004
#define IDC_RED                         20005
#define IDC_MAGENTA                     20006
#define IDC_YELLOW                      20007
#define IDC_WHITE                       20008

#define ID_DRAW_LINE                    30001
#define ID_DRAW_SQUARE                  30002
#define ID_DRAW_ELLIPSE                 30003

#define ID_CLEAR                        40001
#define ID_FILE_SAVEAS                  40002
#define ID_FILE_OPEN                    40013
#define ID_FILL_SHAPE                   40004
#define ID_EMPTY_SHAPE                  40005
#define ID_UNDO                         40006
#define ID_REDO                         40007
#define ID_EXIT                         40008

#define ID_COLOR_FRAME                  41001 
#define ID_CHOOSE_COLOR                 41002  
#define ID_CHOOSE_SHAPE                 41003


typedef struct figure
{
	POINT		sPoint1, sPoint2;
	int			sFigure;
	int			sMoved;
	COLORREF	sColor;
}	Figure, *ptrFigure;



//void DrawFigure(HDC,ptrFigure);
//ptrFigure CreateFigure(POINT, POINT, int,COLORREF);

ptrFigure CreateFigure(POINT prmPoint1, POINT prmPoint2, int prmFigure,COLORREF prmColor)
{
	ptrFigure tmpFigure = (ptrFigure) malloc(sizeof(Figure)); 
			tmpFigure->sPoint1=prmPoint1;
			tmpFigure->sPoint2=prmPoint2;
			tmpFigure->sMoved = 0;
			 
			tmpFigure->sFigure = prmFigure;
			tmpFigure->sColor=prmColor;
	return tmpFigure;
}
void DrawFigure(HDC hdc, ptrFigure prmFigure)
{  
	  RECT  rcRect;
	  HPEN hPen = CreatePen( PS_SOLID, 2, RGB(0,0,0));
	  HBRUSH hBrush ;
	  TCHAR  redstr[4];
	  //GetDlgItemText(hEditr,ID_EDITR, redstr, 3);
	
	  hBrush = CreateSolidBrush(prmFigure->sColor);
	  
	  SelectObject(hdc, hPen);
	  SelectObject(hdc, hBrush);
	  switch(prmFigure->sFigure)
	  {
	  case ID_DRAW_SQUARE:
		  rcRect.left = prmFigure->sPoint1.x; rcRect.top = prmFigure->sPoint1.y;
		  rcRect.right = prmFigure->sPoint2.x; rcRect.bottom = prmFigure->sPoint2.y;
		  FillRect(hdc,&rcRect,hBrush );
		  Rectangle(hdc,prmFigure->sPoint1.x,prmFigure->sPoint1.y,prmFigure->sPoint2.x,prmFigure->sPoint2.y);

		  break;
	  case ID_DRAW_ELLIPSE:
		  
		  Ellipse(hdc,prmFigure->sPoint1.x,prmFigure->sPoint1.y,prmFigure->sPoint2.x,prmFigure->sPoint2.y);
		  
		  break;
	  default: //ID_DRAW_LINE
		  MoveToEx(hdc,prmFigure->sPoint1.x,prmFigure->sPoint1.y,NULL);
		  LineTo(hdc,prmFigure->sPoint2.x,prmFigure->sPoint2.y);
		  break;
	  }
	 
}





